package com.ksd.pug.thread.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ksd.pug.clound.api.UserServiceFegin;
import com.ksd.pug.thread.pojo.SysUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 飞哥
 * @Title: 学相伴出品
 * @Description: 飞哥B站地址：https://space.bilibili.com/490711252
 * 记得关注和三连哦！
 * @Description: 我们有一个学习网站：https://www.kuangstudy.com
 * @date 2022/2/25 15:47
 */
@RestController
@RequestMapping("/consumer")
@Slf4j
public class UserController {

    @Autowired
    private UserServiceFegin userServiceFegin;

    @GetMapping("/user/{id}")
    public SysUser findUsers(@PathVariable("id") Long id) {
       log.info("--------findUsers");
       return  userServiceFegin.findUsers(id);
    }

    @GetMapping("/user/list")
    public List<SysUser> listUser() {
        return userServiceFegin.listUser();
    }

    @GetMapping("/user/listpage")
    public List<SysUser> listUserPage(Integer pageNo, Integer pageSize) {
        return userServiceFegin.listUserPage(pageNo, pageSize);
    }

    @GetMapping("/user/page")
    public Page<SysUser> pageUser(Integer pageNo, Integer pageSize) {
        return userServiceFegin.pageUser(pageNo, pageSize);
    }


    @PostMapping("/user/saveorupdate")
    public int saveOrUpdateUser(@RequestBody SysUser sysUser) {
        return userServiceFegin.saveOrUpdateUser(sysUser);
    }


    @DeleteMapping("/user/del/{id}")
    public int delUserById(@PathVariable("id") Long id) {
        return userServiceFegin.delUserById(id);
    }

}
